package com.paperobot.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.paperobot.dao.BaseDao;
import com.paperobot.dao.PaperDao;
import com.paperobot.model.Paper;

@Repository("paperDao")
public class PaperDaoImpl extends BaseDao implements PaperDao{

	public Paper getPaper(Long paperId) throws Exception {
		return (Paper) getObject("getPaper", paperId);
	}

	@SuppressWarnings("unchecked")
	public List<Paper> getPaperList(Map<String, Object> map) throws Exception {
		return (List<Paper>) getObjects("getPaperList", map);
	}

	
	public Long addPaper(Paper paper) throws Exception {
		Object obj=	saveObject("addPaper", paper);
		if(null!=obj){
			return (Long)obj;
		}
		return -1L;
	}

	public int updatePaper(Paper paper) throws Exception {
		return updateObject("updatePaper", paper);
	}

	public int deletePaper(Long paperId) throws Exception {
		return deleteObject("deletePaper", paperId);
	}

	@SuppressWarnings("unchecked")
	public List<Paper> getHotPaperList(Map<String, Object> map)
			throws Exception {
		return (List<Paper>) getObjects("getHotPaperList", map);
	}

	@SuppressWarnings("unchecked")
	public List<Paper> getRecommendPaperList(Map<String, Object> map)
			throws Exception {
		return (List<Paper>) getObjects("getRecommendPaperList", map);
	}

	public int updatePaperClickNum(Long paperId) throws Exception {
		return updateObject("updatePaperClickNum", paperId);
	}

	@SuppressWarnings("unchecked")
	public List<Paper> findPaperList(String title) throws Exception {
		return (List<Paper>) getObjects("findPaperList", title);
	}

}
